package com.indobrains.uud1945;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
 

public class MainActivity extends Activity implements OnClickListener {
	private static final String PAGE_NO="PAGE_NO";
	private static final String PAGE_TITLE="PAGE_TITLE";
	private Button btnEnter;
//	private Button btnChapter;
//	private Button btnAbout;
	Intent intent;
	Bundle bundle;
	public static final String MY_AD_UNIT_ID="a1519e4461bf94f";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		btnEnter=(Button)findViewById(R.id.btnEnter);
//		btnChapter=(Button)findViewById(R.id.btnChapter);
//		btnAbout=(Button)findViewById(R.id.btnAbout);
		btnEnter.setOnClickListener(this);
//		btnChapter.setOnClickListener(this);
//		btnAbout.setOnClickListener(this);
		AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
        
        LinearLayout layout = (LinearLayout)findViewById(R.id.bannerLayout);
        
        layout.addView(adView);
         
        adView.loadAd(new AdRequest());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()){
		 
		case R.id.btnEnter:
			//startApp(ChapterActivity.class,1,"Daftar Isi");
			intent=new Intent(this,ChapterActivity.class);
			startActivity(intent);
			break;
		 
		}
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		//return super.onOptionsItemSelected(item);
		switch(item.getItemId()){
		case R.id.preface:
			intent=new Intent(this,ContentActivity.class);
	    	bundle = new Bundle();
	    	bundle.putInt(PAGE_NO, 0); //Your id
	    	bundle.putString(PAGE_TITLE, "Kata Pengantar");
			intent.putExtras(bundle);
	    	startActivity(intent);
	    	break;
		case R.id.preambule:
			intent=new Intent(this,ContentActivity.class);
			bundle = new Bundle();
			bundle.putInt(PAGE_NO, 1); //Your id
			bundle.putString(PAGE_TITLE, "Pembukaan");
			intent.putExtras(bundle);
	    	startActivity(intent); 
			break;
		case R.id.about:
			intent=new Intent(this,ContentActivity.class);
			bundle = new Bundle();
			bundle.putInt(PAGE_NO, 2); //Your id
			bundle.putString(PAGE_TITLE, "Tentang Program");
			intent.putExtras(bundle);
	    	startActivity(intent); 
			break;
		case R.id.chapter:
			intent=new Intent(this,ChapterActivity.class);
			startActivity(intent);
			break;
		}
		return false;
	}

	 

}
